( function()
{
	$( document ).ready( function()
	{
		oTable = $( '#customersTbl' ).dataTable( {
			// 0,1,2,3...
			"aaSorting": [ [ 1, "asc" ] ],
			"bJQueryUI": true,
			"sPaginationType": "full_numbers",
			"bAutoWidth": false,
			"oLanguage": {
				"sSearch": "Search the customer: "
			},
			// "sDom": '<"H"lfrT>t<"F"ip>T'
			"sDom": '<"H"lfr>t<"F"ip>',
			/* "aoColumnDefs": [{"sWidth": "30px", "aTargets": [ 0 ]}, { "sClass": "center", "aTargets": [ 0 ] }] */
			"aoColumns": [ {
				"sWidth": "10%"
			}, {
				"sWidth": "20%"
			}, {
				"sWidth": "20%"
			}, {
				"sWidth": "20%"
			}, {
				"sWidth": "15%"
			}, {
				"sWidth": "15%"
			} ]
		} );

		oTable.$( 'tr' ).click( function()
		{
			if( $( this ).hasClass( 'row_selected' ) ){
				$( this ).removeClass( 'row_selected' );
			}
			else{
				oTable.$( 'tr.row_selected' ).removeClass( 'row_selected' );
				$( this ).addClass( 'row_selected' );
			}

			var data = oTable.fnGetData( this );
			alert( data.toString() );
			// ... do something with the array / object of data for the row
		} );

	} );

	function bindEvents()
	{
		$( SEL().customerArea.customerListArea ).addClass( CLASS().hide );
	}

} )();

function signOnToLaundrySystem()
{
	var username = $( SEL().loginArea.usernameInput ).val();
	var password = $( SEL().loginArea.passwordInput ).val();
	var loginValid = validateUsernamePassword( username, password );

	if( loginValid ){

		$( SEL().customerArea.customerListArea ).removeClass( CLASS().hide );
		$( SEL().loginArea.loginArea ).addClass( CLASS().hide );
		// window.location.href = "laundry.html";
		$( SEL().mainMenuArea.mainMenuArea ).removeClass( CLASS().hide );

	}
}

function validateUsernamePassword( username, password )
{
	if( ( username.length == 0 ) && ( password.length == 0 ) ){
		$( '#passwordInfo' ).text( 'There is no password specified. Please enter a password' ).addClass(
						CLASS().errorText );
		$( '#usernameInfo' ).text( 'There is no user ID specified. Please enter a user ID' ).addClass(
						CLASS().errorText );
		return false;
	}
	else{
		if( username.length !== 0 ){
			$( '#usernameInfo' ).text( '' );
			if( password.length !== 0 ){
				$( '#passwordInfo' ).text( '' );
				return true;
			}
			else{
				$( '#passwordInfo' ).text( 'There is no password specified. Please enter a password' ).addClass(
								CLASS().errorText );
				return false;
			}
		}
		else{
			$( '#usernameInfo' ).text( 'There is no user ID specified. Please enter a user ID' ).addClass(
							CLASS().errorText );
			if( password.length !== 0 ){
				$( '#passwordInfo' ).text( '' );
			}
			else{
				$( '#passwordInfo' ).text( 'There is no password specified. Please enter a password' ).addClass(
								CLASS().errorText );
			}
			return false;
		}
	}
}
